package notesDetection.GUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class AboutWindow implements ActionListener {

	private JPanel pnlCenter;
	private JTextArea textMain;
	private JDialog mainDialog;
	
	
	public AboutWindow(JFrame superFrame)
	{
		mainDialog = new JDialog(superFrame, "About NOTES");	
		mainDialog.setPreferredSize(new Dimension(200, 150));
        
        //	Configure text
        textMain = new JTextArea("Notes Detector 2012\n\n" + "Developed by Guy in \"Codes and learning functions workshop\" under supervision of Muli and Aviad");
        textMain.setBackground(mainDialog.getBackground());
        textMain.setLineWrap(true);
        textMain.setWrapStyleWord(true);
        textMain.setEnabled(false);
        textMain.setPreferredSize(new Dimension(180, 150));
        
        pnlCenter = new JPanel();
        pnlCenter.add(textMain);
        
        // Setup Main Frame
        mainDialog.getContentPane().setLayout(new BorderLayout());
        mainDialog.getContentPane().add(pnlCenter, BorderLayout.CENTER);	
        
        URL inverseIcon = getClass().getResource("/notesDetection/GUI/resources/noteIconInverse.jpg");
        
        //String _currentDir = new File("").getAbsolutePath();
        //String iconRelativePath = "\\bin\\notesDetection\\GUI\\resources\\noteIconInverse.jpg";
        
        mainDialog.setIconImage(LogoImage.loadImage(inverseIcon));
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		displayFrame();
		
	}

	private void displayFrame() {
		// Display Frame
		mainDialog.setResizable(false);
		mainDialog.pack(); //Adjusts panel to components for display
		mainDialog.setVisible(true);
		
	}
	

}
